#include <iostream>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <math.h>
#include <algorithm>
#include <string>
#include <stack>
using namespace std;

bool isValid(string s) {
    short size=s.size();
    stack<char>result;
    for(short i=0;i<size;i++){
        if((s[i]=='(')
        ||(s[i]=='[')
        ||(s[i]=='{')){
            result.push(s[i]);
        }else {
            if(!result.empty()&&(s[i]==')'&&(result.top()=='(')
            ||(s[i]==']'&&result.top()=='[')
            ||(s[i]=='}'&&result.top()=='{')
            )){
                result.pop();
            }
            else return false;
        }
    }
    return result.empty();
}

int main(){
    cout<<isValid("{[]}(())");
    return 0;
}